package com.blocks.gui;

import com.blocks.ScriptBlocksApplication;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.Label;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

public class MainMenuScreenController implements ScreenController {
	Nifty nifty;
	private Label label;
	@Override
	public void bind(Nifty nifty, Screen screen) {
		this.nifty = nifty;
		this.label = screen.findNiftyControl("label1", Label.class);
		this.label.setText(ScriptBlocksApplication.getInstance().getLevelProperties().getLevelDescription());
	}


	public void startGame() {
		ScriptBlocksApplication.getInstance().gameState();
		ScriptBlocksApplication.getInstance().setNiftyActive(false);
		nifty.exit();
		
		
	}
	public void startSandboxGame() {
		nifty.fromXml("Interfaces/niftytest.xml", "start");
	}

	
	public void quitGame() {
		ScriptBlocksApplication.getInstance().stop();

	}
	public void reloadLevel() {				
		ScriptBlocksApplication.getInstance().newGame();
		ScriptBlocksApplication.getInstance().loadLevel(ScriptBlocksApplication.getInstance().getLevelProperties().getLevelFileName(), false);	
		this.label.setText(ScriptBlocksApplication.getInstance().getLevelProperties().getLevelDescription());
	}
	public void nextLevel() {		
		ScriptBlocksApplication.getInstance().newGame();
		ScriptBlocksApplication.getInstance().loadLevel(ScriptBlocksApplication.getInstance().getLevelProperties().getNextLevelFileName(), false);
		this.label.setText(ScriptBlocksApplication.getInstance().getLevelProperties().getLevelDescription());
	}

	@Override
	public void onEndScreen() {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void onStartScreen() {
		// TODO Auto-generated method stub
		
	}

}	
	
